<?php
/**
 * OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures
 * all the essential functionalities required for any enterprise.
 * Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com
 *
 * OrangeHRM is free software; you can redistribute it and/or modify it under the terms of
 * the GNU General Public License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with this program;
 * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA  02110-1301, USA
 *
 */
$styleSheet = "orange";
$pageNO = isset($_POST['pageNO'])?$_POST['pageNO']:'1';

	function getNextSortOrder($curSortOrder) {
		switch ($curSortOrder) {
			case 'null' :
				return 'ASC';
				break;
			case 'ASC' :
				return 'DESC';
				break;
			case 'DESC'	:
				return 'ASC';
				break;
		}
	}
	
	    $GLOBALS['lang_Common_SortAscending'] = $lang_Common_SortAscending;
    $GLOBALS['lang_Common_SortDescending'] = $lang_Common_SortDescending;

	function nextSortOrderInWords($sortOrder) {
        return $sortOrder == 'ASC' ? $GLOBALS['lang_Common_SortDescending'] : $GLOBALS['lang_Common_SortAscending'];
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="../../themes/<?php echo $styleSheet; ?>/css/style.css" rel="stylesheet" type="text/css"/>
<!--[if lte IE 6]>
<link href="../../themes/<?php echo $styleSheet; ?>/css/IE6_style.css" rel="stylesheet" type="text/css"/>
<![endif]-->
<!--[if IE]>
<link href="../../themes/<?php echo $styleSheet; ?>/css/IE_style.css" rel="stylesheet" type="text/css"/>
<![endif]-->
<script type="text/javascript" src="../../themes/<?php echo $styleSheet;?>/scripts/style.js"></script>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script type="text/javascript" src="../../scripts/octopus.js"></script>
<script type="text/javascript">

	function nextPage() {
		i=document.standardView.pageNO.value;
		i++;
		document.standardView.pageNO.value=i;
		document.standardView.submit();
	}

	function prevPage() {
		var i=document.standardView.pageNO.value;
		i--;
		document.standardView.pageNO.value=i;
		document.standardView.submit();
	}

	function chgPage(pNO) {
		document.standardView.pageNO.value=pNO;
		document.standardView.submit();
	}
	
	function returnDelete() {
		$check = 0;
		with (document.standardView) {
			for (var i=0; i < elements.length; i++) {
				if ((elements[i].type == 'checkbox') && (elements[i].checked == true)){
					$check = 1;
				}
			}
		}

		if ( $check == 1 ){
			document.standardView.delState.value = 'DeleteMode';
			document.standardView.pageNO.value=1;
			document.standardView.submit();
		}else{
			alert("<?php echo $lang_Error_SelectAtLeastOneRecordToDelete; ?>");
		}
	}


	function returnSearch() {
		if (document.standardView.loc_code.value == -1) {
			alert("<?php echo $lang_Common_SelectField; ?>");
			document.standardView.loc_code.Focus();
			return;
		};
		document.standardView.captureState.value = 'SearchMode';
		document.standardView.pageNO.value=1;
		document.standardView.submit();
	}

	function doHandleAll()
	{
		with (document.standardView) {
			if(elements['allCheck'].checked == false){
				doUnCheckAll();
			}
			else if(elements['allCheck'].checked == true){
				doCheckAll();
			}
		}
	}

	function doCheckAll() {
		with (document.standardView) {
			for (var i=0; i < elements.length; i++) {
				if (elements[i].type == 'checkbox') {
					elements[i].checked = true;
				}
			}
		}
	}

	function doUnCheckAll()
	{
		with (document.standardView) {
			for (var i=0; i < elements.length; i++) {
				if (elements[i].type == 'checkbox') {
					elements[i].checked = false;
				}
			}
		}
	}
	
	/**
	 * If at least one day is unchecked, main check box would be unchecked
	 */

	function unCheckMain() {
		noOfCheckboxes = 0;
		noOfCheckedCheckboxes = 0;

		with (document.getElementById('standardView')) {
			for (i = 0; i < elements.length; i++) {
				if (elements[i].type == 'checkbox' && elements[i].name != 'allCheck') {
					noOfCheckboxes++;
					if (elements[i].checked == true) {
						noOfCheckedCheckboxes++;
					}

				}
			}
		}

		document.getElementById('allCheck').checked = (noOfCheckboxes == noOfCheckedCheckboxes);
	}

	function clear_form() {
		document.standardView.loc_code.options[0].selected=true;
		document.standardView.loc_name.value='';
	}
	
	function examSalary() {
		document.standardView.captureState.value = 'AddMode';
		//document.standardView.pageNO.value=1;
		document.standardView.action = '<?php echo $_SERVER['PHP_SELF']?>?salcode=budget&action=ExamSalaryReport';
		document.standardView.submit();
	}
</script>
<div class="outerbox">
	<form name="standardView" id="standardView" method="post" action="<?php echo $_SERVER['PHP_SELF']?>?salcode=budget&action=<?php echo $records['action'];?>&sortField=<?php echo $this->getArr['sortField']; ?>&amp;sortOrder<?php echo $this->getArr['sortField']; ?>=<?php echo $this->getArr['sortOrder'.$this->getArr['sortField']]?>">

		<div class="mainHeading"><h2>月度工资预算表</h2></div>
		<input type="hidden" name="captureState" value="<?php echo isset($this->postArr['captureState'])?$this->postArr['captureState']:''?>" />
		<input type="hidden" name="pageNO" value="<?php echo $pageNO;?>" />
		<input type="hidden" name="empID" value="" />


		<?php include("../../templates/salary/Search.php");?>

		<?php
		if (isset($_GET['message'])) {
			$expString  = $_GET['message'];
			$messageType = CommonFunctions::getCssClassForMessage($expString);
			$messageType = 'failure';
		?>
		<div class="messagebar">
			<span class="<?php echo $messageType; ?>"><?php echo $expString; ?></span>
		</div>
		<?php
		}
		?>
			
		<div class="actionbar">
				<div class="actionbuttons">
					<?php $locRights['add']=true;?>
					<input type="button" class="plainbtn"
					<?php echo ($locRights['add']) ? 'onclick="examSalary();"' : 'style=visibility:hidden;'; ?>
						onmouseover="this.className='plainbtn plainbtnhov'" onmouseout="this.className='plainbtn'"
						value="审核生成该月的工资预算报表" />


						<input type="button" class="plainbtn"
						<?php echo ($locRights['delete']) ? 'onclick="returnDelete();"' : 'style=visibility:hidden;'; ?>
							onmouseover="this.className='plainbtn plainbtnhov'" onmouseout="this.className='plainbtn'"
							value="<?php echo $lang_Common_Delete;?>" />


				</div>
				<div class="noresultsbar"><?php echo (empty($emplist)) ? $norecorddisplay : '';?></div>
				<div class="pagingbar">
				<?php
					$commonFunc = new CommonFunctions();
					$pageStr = $commonFunc->printPageLinks($records['Allcount'], $pageNO);
	
					$pageStr = preg_replace(array('/#first/', '/#previous/', '/#next/', '/#last/'), array($lang_empview_first, $lang_empview_previous, $lang_empview_next, $lang_empview_last), $pageStr);

					echo $pageStr;

					/*for ($j = 0; $j < 11; $j++) {
						if (!isset($this->getArr['sortOrder'.$j])) {
							$this->getArr['sortOrder'.$j] = 'null';
						}
					}*/
				?>
				</div>
			<br class="clear" />
			</div>
			<br class="clear" />
				<table cellspacing="0" cellpadding="0" class="data-table" border="1">
					<thead>
					<tr align="center">
						<!--<td width="50">
	
							<input type="checkbox" name="allCheck" id="allCheck" class="checkbox" style="margin-left:1px"
								onclick="doHandleAll()" />
				
						</td>-->
						<td scope="col">序号</td>
						<td scope="col">部门</td>
						<td scope="col">员工姓名</td>
						<td scope="col">员工ID</td>
						<td scope="col">进厂日期</td>
						<!--td scope="col">开始课长/职员</td-->
						<td scope="col">总服务年</td>
						<!--td scope="col">服务年</td-->
						<td scope="col">年功</td>
						<td scope="col">月份</td>
						<td scope="col">时薪</td>
						<td scope="col">出勤</td>
						<td scope="col">A基本工资</td>
						<td scope="col">学历</td>
						<td scope="col">等级津贴</td>
						<td scope="col">职位</td>
						<td scope="col">评估奖金</td>
						<td scope="col">技能津贴</td>
						<td scope="col">B津贴合计</td>
						<td scope="col">OT*1.5小时</td>
						<td scope="col">OT*2.0小时</td>
						<td scope="col">OT*3.0小时</td>
						<td scope="col">OT*1.5</td>
						<td scope="col">OT*2.0</td>
						<td scope="col">OT*3.0</td>
						<td scope="col">C总费用</td>
						<td scope="col">倒班夜餐</td>
						<td scope="col">D奖励</td>
						<td scope="col">其他</td>
						<td scope="col">D其他总和</td>
						<td scope="col">X当月工资(PI)</td>
						<td scope="col">Y应扣部分</td>
						<td scope="col">TB税前工资(X-Y)</td>
						<td scope="col">免税额</td>
						<td scope="col">应交税金额</td>
						<td scope="col">税率</td>
						<td scope="col">速減金额</td>
						<td scope="col">个人所得税</td>
						<td scope="col">当月实付工资</td>
					</tr>
					</thead>

					<tbody>
					<?php
							$list = $records['list'];
							$sysConst = new sysConf();
							
							for ($j=0; $j<count($list);$j++) {

					?>
								<tr class="<?php echo $cssClass;?>" style="text-align:center">

									<td scope="col"><?php echo ($pageNO-1)*$sysConst->itemsPerPage+$j+1?></td>
									<td scope="col"><?php echo $list[$j]['department']?></td>
								
									<td scope="col"><?php echo $list[$j]['emp_name']?></td>
									<td scope="col"><?php echo $list[$j]['emp_number']?></td>
									<td scope="col"><?php echo $list[$j]['join_date']?></td>
									
									<!--td scope="col"><?php echo $list[$j]['effective_date']?></td-->
									<td scope="col"><?php echo round((time()-strtotime($list[$j]['join_date']))/31536000,2)?></td>
									
									<!--td scope="col"><?php echo round((time()-strtotime($list[$j]['effective_date']))/31536000,2)?></td-->
									<td scope="col"><?php echo $list[$j]['niangong']?></td>
									
									<td scope="col"><?php echo $list[$j]['year'].'-'.$list[$j]['month']?></td>
									<td scope="col"><?php echo $list[$j]['hour_salary']?></td>
									<td scope="col"><?php echo $list[$j]['A_attendance_hours']?></td>
									<td scope="col"><?php echo $list[$j]['A_total']?></td>
									
									<td scope="col"><?php echo $list[$j]['B_education']?></td>
									<td scope="col"><?php echo $list[$j]['B_manager']?></td>
									<td scope="col"><?php echo $list[$j]['B_job']?></td>
									<td scope="col"><?php echo $list[$j]['B_award']?></td>
									<td scope="col"><?php echo $list[$j]['B_skill_alw']?></td>
									<td scope="col"><?php echo $list[$j]['B_total']?></td>
									
									<td scope="col"><?php echo $list[$j]['C_OT_hours15']?></td>
									<td scope="col"><?php echo $list[$j]['C_OT_hours2']?></td>
									<td scope="col"><?php echo $list[$j]['C_OT_hours3']?></td>
									
									<td scope="col"><?php echo $list[$j]['C_OT_salary15']?></td>
									<td scope="col"><?php echo $list[$j]['C_OT_salary2']?></td>
									<td scope="col"><?php echo $list[$j]['C_OT_salary3']?></td>
									
									<td scope="col"><?php echo $list[$j]['C_total']?></td>
									
									<td scope="col"><?php echo $list[$j]['night_snack_fee']?></td>
									<td scope="col"><?php echo $list[$j]['D_award']?></td>
									<td scope="col"><?php echo $list[$j]['D_other']?></td>
									
									<td scope="col"><?php echo $list[$j]['D_total']?></td>
									<td scope="col"><?php echo $list[$j]['PI_salary']?></td>
									
									<td scope="col"><?php echo $list[$j]['Y_total']?></td>
									<td scope="col"><?php echo $list[$j]['TB_salary']?></td>
									
									<td scope="col"><?php echo $list[$j]['M_total']?></td>
									<td scope="col"><?php echo $list[$j]['T_total']?></td>
									<td scope="col"><?php echo $list[$j]['tax_rate']."%"?></td>
									<td scope="col"><?php echo $list[$j]['minus_amount']?></td>
									<td scope="col"><?php echo $list[$j]['tax']?></td>
									
									<td scope="col"><?php echo $list[$j]['actual_sarlary']?></td>

	
							</tr>
						<?php } ?>
					</tbody>
				</table>
	</form>
</div>
<script type="text/javascript">
//<![CDATA[
    if (document.getElementById && document.createElement) {
        roundBorder('outerbox');
    }
//]]>
</script>
